import 'child.dart';

class Menu {
  int? id;
  int? parentId;
  String? name;
  String? path;
  String? component;
  String? componentName;
  String? icon;
  bool? visible;
  bool? keepAlive;
  bool? alwaysShow;
  List<Child>? children;

  Menu({
    this.id,
    this.parentId,
    this.name,
    this.path,
    this.component,
    this.componentName,
    this.icon,
    this.visible,
    this.keepAlive,
    this.alwaysShow,
    this.children,
  });

  factory Menu.fromJson(Map<String, dynamic> json) => Menu(
        id: json['id'] as int?,
        parentId: json['parentId'] as int?,
        name: json['name'] as String?,
        path: json['path'] as String?,
        component: json['component'] as String?,
        componentName: json['componentName'] as String?,
        icon: json['icon'] as String?,
        visible: json['visible'] as bool?,
        keepAlive: json['keepAlive'] as bool?,
        alwaysShow: json['alwaysShow'] as bool?,
        children: (json['children'] as List<dynamic>?)
            ?.map((e) => Child.fromJson(e as Map<String, dynamic>))
            .toList(),
      );

  Map<String, dynamic> toJson() => {
        'id': id,
        'parentId': parentId,
        'name': name,
        'path': path,
        'component': component,
        'componentName': componentName,
        'icon': icon,
        'visible': visible,
        'keepAlive': keepAlive,
        'alwaysShow': alwaysShow,
        'children': children?.map((e) => e.toJson()).toList(),
      };
}
